import request from '@/utils/request'

export function addRole(data) { //新增角色
  return request({
    url: '/upms/role',
    method: 'post',
    data
  })
}

export function compileRole (data) { //编辑角色
  return request({
    url :'/upms/role/permission',
    method: 'put',
    data
  })
}

export function searchList (roleName,roleId,roleTags) { //拉取角色的列表
  var data = {
    roleName : roleName,
    roleId : roleId,
    roleTags :roleTags
  }
  JSON.stringify(data)
  return request({
    url :'/upms/role/search',
    method: 'get',
    params : data
  })
}


export function del (roleId) { //删除角色
  return request({
    url :'/upms/role',
    method: 'DELETE',
    params: { roleId }
  })
}

export function roleMenu () {//配置权限拉取菜单
  return request({
    url :'/upms/menu/all',
    method: 'get',
  })
}
export function operation (menuId) {//获取资源列表
  return request({
    url :'/upms/operation',
    method: 'get',
    params: { menuId }
  })
}

export function whatPermission (roleId) { //这个角色有什么权限
  return request({
    url :'/upms/role/permission',
    method: 'get',
    params: { roleId }
  })
}
export function addPermission (data) { //添加角色权限
  return request({
    url :'/upms/role/permission',
    method: 'post',
    data
  })
}
export function addRoleMenu (data) {//菜单确定
  return request({
    url :'/upms/role/permission',
    method: 'post',
    data
  })
}
